if(NOT parallel)
  return()
endif()

# testing what we just built

set(_sfilename input_simpletest_real)
set(_dfilename input_simpletest_real)
set(_cfilename input_simpletest_cmplx)
set(_zfilename input_simpletest_cmplx)

foreach(a ${arith})
  add_executable(${a}simpletest ${a}simpletest.F)
  target_link_libraries(${a}simpletest PRIVATE mumps::mumps ${NUMERIC_LIBS})
  target_include_directories(${a}simpletest PRIVATE ${NUMERIC_INCDIRS})
  if(UNIX)
    add_test(NAME mumps:example_${a} COMMAND sh -c "${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:${a}simpletest> < ${CMAKE_CURRENT_SOURCE_DIR}/${_${a}filename}")
    set_tests_properties(mumps:example_${a} PROPERTIES RUN_SERIAL true)
  endif()

  add_executable(${a}simpletest_save_restore ${a}simpletest_save_restore.F)
  target_link_libraries(${a}simpletest_save_restore PRIVATE mumps::mumps ${NUMERIC_LIBS})
  target_include_directories(${a}simpletest_save_restore PRIVATE ${NUMERIC_INCDIRS})
  if(UNIX)
    add_test(NAME mumps:saveRestore_${a} COMMAND sh -c "${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:${a}simpletest_save_restore> < ${CMAKE_CURRENT_SOURCE_DIR}/${_${a}filename}")
    set_tests_properties(mumps:saveRestore_${a} PROPERTIES RUN_SERIAL true)
  endif()
endforeach()

if(NOT ClangTest)
  return()
endif()

if("d" IN_LIST arith)
  add_executable(c_example c_example.c)
  target_link_libraries(c_example PRIVATE dmumps mumps::mumps ${NUMERIC_LIBS})
  target_include_directories(c_example PRIVATE ${NUMERIC_INCDIRS})
  add_test(NAME mumps:example_C COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:c_example>)
  set_tests_properties(mumps:example_C PROPERTIES RUN_SERIAL true)
endif()